clear all

import delimited "cohort2_public_0-48m_5.18.23.csv"

rename public_id id

rename qsurveyyear year
rename qsurveymonth month
rename qweight_p person_weight
rename qweight_pu poverty_weight

gen own_rent = qa1
label define ownlabel 1 "Rent" 2 "Own" 3 "live with family, pay part rent" 4 "live with family, pay no rent" 5 "rent a room, not form family" 6 "live in apt/house owned by other" 7 "live in temporary housing" 8 "live on street or park" 9 "other arrangement"
label val own_rent ownlabel
replace own_rent = . if own_rent > 9
order own_rent, after(qa1)
drop qa1

gen homeowner = 0 if own_rent !=2
replace homeowner = 1 if own_rent ==2
lab define ownlab 0 "No" 1 "Yes"
lab val homeowner ownlab

gen renter=0 if own_rent !=1 | own_rent !=4 | own_rent !=5
replace renter=1 if own_rent ==1 | own_rent==4 | own_rent==5
lab define rentlab 0 "No" 1 "Yes"
lab val renter rentlab
order homeowner renter, after(own_rent)

gen gender = qa3_gender
label define genderlabel 1 "male" 2 "female"
label val gender genderlabel
replace gender = . if gender==97
gen male =0 if gender !=1
replace male=1 if gender==1
gen female =0 if gender !=2
replace female =1 if gender ==2
drop qa3_gender
order gender male female, after(renter)

rename qa3_age_tc age
replace age = . if age ==999

rename qa4 others_inhome1
replace others_inhome1 = . if others_inhome1 > 2
rename qa4_rel1 others_relation1
replace others_relation1 =. if others_relation1==97
rename qa4_age1_tc others_age1
replace others_age1=. if others_age1==977
rename qa4_gender1 others_gender1
replace others_gender1 = . if others_gender1==97


rename qa4_rel2 others_relation2
replace others_relation2 =. if others_relation2==97
rename qa4_age2_tc others_age2
replace others_age2=. if others_age2==977
rename qa4_gender2 others_gender2
replace others_gender2 = . if others_gender2==97

rename qa4_rel3 others_relation3
replace others_relation3 =. if others_relation3==97
rename qa4_age3_tc others_age3
replace others_age3=. if others_age3==977
rename qa4_gender3 others_gender3
replace others_gender3 = . if others_gender3==97

rename qa4_rel4 others_relation4
replace others_relation4 =. if others_relation4==97
rename qa4_age4_tc others_age4
replace others_age4=. if others_age4==977
rename qa4_gender4 others_gender4
replace others_gender4 = . if others_gender4==97

rename qa8x_tc monthly_rent
rename qa9a rent_controlled
rename qa10x_tc monthly_mortgage

gen monthly_rent_mortgage = monthly_rent if monthly_rent !=.
replace monthly_rent_mortgage = monthly_mortgage if monthly_mortgage !=.
replace monthly_rent_mortgage = 0 if own_rent ==4

rename qa11 bedrooms
rename qb1 neighborhood_rating
replace neighborhood_rating =. if neighborhood_rating > 5
rename qb3 nyc_rating
replace nyc_rating =. if nyc_rating > 5

rename qc1 freefood
recode freefood (2=0) 
lab define foodlab 0 "No" 1 "Yes"
label val freefood foodlab
replace freefood =. if freefood > 2

rename qc2 freefood_howoften
replace freefood_howoften =. if freefood_howoften > 5

rename qc3 homeless_facility
recode homeless_facility (2=0)
lab define faclabel 0 "No" 1 "Yes"
lab val homeless_facility faclabel
drop if homeless_facility > 2

rename qc4x homeless_facility_nights

rename qc5_1 assist_jobtrain
rename qc5_2 assist_educ
rename qc5_3 assist_housing
rename qc5_4 assist_finances
rename qc5_5 assist_obtainingbenefits
rename qc5_6 assist_healthservices
rename qc5_7 assist_counseling
rename qc5_8 assist_childcare
rename qc5_9 assist_parenting
rename qc5_10 assist_legal
rename qc5_11 assist_mentoring
rename qc5_12 assist_else

rename qc6 visit_communityorg_times
replace visit_communityorg_times =. if visit_communityorg_times > 6

rename qd1 generalhealth_rating
replace generalhealth_rating = . if generalhealth_rating > 5
recode generalhealth_rating (5=1) (4=2) (2=4) (1=5)
lab define healthlab 1 "Poor" 2 "Fair" 3 "Good" 4 "Very Good" 5 "Excellent"
label val generalhealth_rating healthlab

rename qd1_sp spousehealth_rating
replace spousehealth_rating = . if spousehealth_rating > 5
recode spousehealth_rating (5=1) (4=2) (2=4) (1=5)
lab define shealthlab 1 "Poor" 2 "Fair" 3 "Good" 4 "Very Good" 5 "Excellent"
label val spousehealth_rating shealthlab

rename qd2 disability_preventwork
recode disability_preventwork (2=0)
lab define dislab 0 "No" 1 "Yes"
label val disability_preventwork dislab
replace disability_preventwork = . if disability_preventwork > 2

rename qd2 spouse_preventwork
recode spouse_preventwork (2=0)
lab define sdislab 0 "No" 1 "Yes"
label val spouse_preventwork sdislab
replace spouse_preventwork = . if spouse_preventwork > 2

rename qd3 depressed_2weeks
recode depressed_2weeks (2=0)
lab define deplab 0 "No" 1 "Yes"
label val depressed_2weeks deplab
replace depressed_2weeks=. if depressed_2weeks >2

rename qd4 stressed_anxious_1month
recode stressed_anxious_1month (2=0)
lab define stresslab 0 "No" 1 "Yes"
label val stressed_anxious_1month stresslab
replace stressed_anxious_1month=. if stress >2

rename qd5 money_worries_howoften
recode money_worries_howoften (4=1) (3=2) (2=3) (1=4)
lab define moneylab 1 "Never" 2 "Rarely" 3 "Sometimes" 4 "Often"
label val money_worries moneylab
replace money_worries =. if money_worries > 4

rename qd6 life_rating_0_10
replace life_rating_0_10 =. if life_rating_0_10 > 10

rename qf1 food_insufficient
replace food_insufficient = . if food_insufficient > 4

rename qf2 food_runout_worry
recode food_runout_worry (1=3) (3=1)
lab define worrylabel 1 "Never" 2 "Sometimes" 3 "Often"
label val food_runout_worry worrylabel
replace food_runout_worry =. if food_runout_worry > 3

rename qf3 food_ranout
recode food_ranout (1=3) (3=1)
lab define ranoutlabel 1 "Never" 2 "Sometimes" 3 "Often"
lab val food_ranout ranoutlabel
replace food_ranout =. if food_ranout > 3

rename qf4 rent_hardship
recode rent_hardship (2=0) (3=0)
lab define renthlab 0 "No" 1 "Yes"
lab val rent_hardship renthlab
replace rent_hardship = . if rent_hardship > 3

rename qf5 moved_finances
recode moved_finances (2=0)
lab define movlab 0 "No" 1 "Yes"
lab val moved_finances movlab
replace moved_finances =. if moved_finances > 2

rename qf6 moved_temporary
recode moved_temporary (2=0)
lab def movetmplab 0 "No" 1 "Yes"
lab val moved_temporary movetmplab
replace moved_temporary =. if moved_temporary > 1

rename qf7 energy_bill
recode energy_bill (2=0)
lab def enlab 0 "No" 1 "Yes"
lab val energy_bill enlab
replace energy_bill =. if energy_bill > 1

rename qf8 disconnected
recode disconnected (2=0)
lab def discolab 0 "No" 1 "Yes"
lab val disconnected discolab
replace disconnected =. if disconnected >1

rename qf9 skipped_healthcare
recode skipped_healthcare (2=0)
lab def skiplab 0 "No" 1 "Yes"
lab val skipped_healthcare skiplab
replace skipped_healthcare =. if skipped_healthcare > 1

rename qf10 ranout_money
recode ranout_money (3=1) (1=3)
lab def ranlab 1 "Never" 2 "Sometimes" 3 "Often"
label val ranout_money ranlab
replace ranout_money =. if ranout_money > 3

rename imp_qhous1 imp_rent_hardship
recode imp_rent_hardship (2=0)
lab define imprenthlab 0 "No" 1 "Yes"
lab val imp_rent_hardship imprenthlab

rename imp_qhous2 imp_moved_finances
recode imp_moved_finances (2=0)
lab define movfin 0 "No" 1 "Yes"
lab val imp_moved_finances movfin

rename imp_qhous3 imp_moved_temporary
recode imp_moved_temporary (2=0)
lab define impmovtemplab 0 "No" 1 "Yes"
label val imp_moved_temporary impmovtemplab

rename imp_qbill1 imp_energy_bill
recode imp_energy_bill (2=0)
label define impbilllab 0 "No" 1 "Yes"
label val imp_energy_bill impbilllab

rename imp_qbill2 imp_disconnected
recode imp_disconnected (2=0)
label define impdisclab 0 "No" 1 "Yes"
label val imp_disconnected impdisclab

rename imp_qmedic1 imp_skipped_healthcare
recode imp_skipped_healthcare (2=0)
label define impskiplab 0 "No" 1 "Yes"
label val imp_skipped_healthcare impskiplab

rename imp_qfinanc1 imp_ranout_money
recode imp_ranout_money (3=1) (1=3)
lab def impranlab 1 "Never" 2 "Sometimes" 3 "Often"
label val imp_ranout_money impranlab

rename imp_qfood1 imp_food_insufficient

rename imp_qfood2 imp_food_runout_worry
recode imp_food_runout_worry (1=3) (3=1)
lab define impworrylabel 1 "Never" 2 "Sometimes" 3 "Often"
label val imp_food_runout_worry impworrylabel

rename imp_qfood3 imp_food_ranout
recode imp_food_ranout (1=3) (3=1)
lab define impranoutlabel 1 "Never" 2 "Sometimes" 3 "Often"
lab val imp_food_ranout impranoutlabel

rename imp_qbor borough

rename imp_qsnapyes imp_snap_12mos
recode imp_snap_12mos (2=0)
lab define impsnaplab 0 "No" 1 "Yes"
lab val imp_snap_12mos impsnaplab

rename imp_qretyes imp_retirement_12mos
recode imp_retirement_12mos (2=0)
lab define impretlab 0 "No" 1 "Yes"
lab val imp_retirement_12mos impretlab

rename imp_qdisyes imp_disability_12mos
recode imp_disability_12mos (2=0)
lab define impdislab 0 "No" 1 "Yes"
lab val imp_disability_12mos impdislab

rename imp_qwelfyes imp_welfare_12mos
recode imp_welfare_12mos (2=0)
lab define impwelflab 0 "No" 1 "Yes"
lab val imp_welfare_12mos impwelflab

rename imp_quiyes imp_unemployment_12mos
recode imp_unemployment_12mos (2=0)
lab define impumplab 0 "No" 1 "Yes"
lab val imp_unemployment_12mos impumplab

rename imp_qregyes imp_regcashassist_12mos
recode imp_regcashassist_12mos (2=0)
lab define impregcashlab 0 "No" 1 "Yes"
lab val imp_regcashassist_12mos impregcashlab

rename imp_qothyes imp_otherbenefits
recode imp_otherbenefits (2=0)
lab define impotherlab 0 "No" 1 "Yes"
lab val imp_otherbenefits impotherlab

rename imp_qhealth imp_genhealth_rating

rename imp_qfoodindmod foodhardship_moderate
recode foodhardship_moderate (2=0)
lab define modfoodhardship 0 "No" 1 "Yes"
lab val foodhardship_moderate modfoodhardship

rename imp_qhouseindmod househardship_moderate
recode househardship_moderate (2=0)
lab define hhhardshiplab 0 "No" 1 "Yes"
lab val househardship_moderate hhhardshiplab

rename imp_qbillindmod energyhardship_moderate
recode energyhardship_moderate (2=0)
lab define ehardshiplab 0 "No" 1 "Yes"
lab val energyhardship_moderate ehardshiplab

rename imp_qfinancindmod financialhardship_moderate
recode financialhardship_moderate (2=0)
lab define finhardshiplab 0 "No" 1 "Yes"
lab val financialhardship_moderate finhardshiplab

rename imp_qfoodindsev foodhardship_severe
recode foodhardship_severe (2=0)
lab define foodhardsevlab 0 "No" 1 "Yes"
lab val foodhardship_severe foodhardsevlab

rename imp_qhouseindsev househardship_severe
recode househardship_severe (2=0)
lab define househardsevlab 0 "No" 1 "Yes"
label val househardship_severe househardsevlab

rename imp_qbillindsev energyhardship_severe
recode energyhardship_severe (2=0)
lab define ehardshipsevlab 0 "No" 1 "Yes"
lab val energyhardship_severe ehardshipsevlab

rename imp_qmedichard medicalhardship_24mos
recode medicalhardship_24mos (2=0)
lab define medhardshiplab 0 "No" 1 "Yes"
lab val medicalhardship_24mos medhardshiplab

rename imp_qfinancindsev financialhardship_severe
recode financialhardship_severe (2=0)
lab define finhardseverelab 0 "No" 1 "Yes"
lab val financialhardship_severe finhardseverelab

rename qg0 workedforpay_lastweek
recode workedforpay_lastweek (2=0)
lab def workedpaylab 0 "No" 1 "Yes"
lab val workedforpay_lastweek workedpaylab
replace workedforpay_lastweek =. if workedforpay_lastweek > 2

rename qg3 spouseworked_lastweek
recode spouseworked_lastweek (2=0)
lab def spouseworklab 0 "No" 1 "Yes"
lab val spouseworked_lastweek spouseworklab
replace spouseworked_lastweek = . if spouseworked_lastweek > 2

rename qh5_6 wic_12mos
recode wic_12mos (2=0)
lab def wiclab 0 "No" 1 "Yes"
lab val wic_12mos wiclab
replace wic_12mos = . if wic_12mos > 2

rename qh5_7 houseassist_12mos
recode houseassist_12mos (2=0)
lab def houseaslab 0 "No" 1 "Yes"
lab val houseassist_12mos houseaslab
replace houseassist_12mos = . if houseassist_12mos > 2

rename qh5_8 medicaid_12mos
recode medicaid_12mos (2=0)
lab def medlab 0 "No" 1 "Yes"
lab val medicaid_12mos medlab
replace medicaid_12mos = . if medicaid_12mos > 2

rename qi3 internet_access
rename qi4 inter_access_mobile

rename qchildx_tc children_under18
rename qadultx_tc hh_adults
rename qpersonx_tc hh_size

rename imp_race race
gen white = 0 if race !=1
replace white = 1 if race==1
gen black = 0 if race !=2
replace black=1 if race==2
gen asian=0 if race !=3
replace asian=1 if race==3
gen race_other=0 if race !=4
replace race_other=1 if race==4
gen hispanic=0 if race !=5
replace hispanic=1 if race==5

rename imp_educat educ
rename imp_qmoswork months_worked
rename imp_qsmoswork spousemonths_worked

rename qsevhard severe_hardship
recode severe_hardship (2=0)
lab def hardlab 0 "No" 1 "Yes"
lab val severe_hardship hardlab

rename qfrsl freelunch_amount
rename qwicval wic_amount

rename imp_qearnhd_tc earnings
rename imp_qearnsp_tc spouse_earnings
rename imp_qincret_tc retirement_earnings
rename imp_qincdis_tc disability_income
rename imp_qincwelf_tc welfare_income
rename imp_qincui_tc unemployment_income
rename imp_qincsnap_tc snap_income
rename qfiitax_tc federal_taxes
rename qsiitax_tc state_taxes
rename qfica_tc fica_taxes
rename qspmpov spm_poverty_status
recode spm_poverty_status (2=0)
lab def spmlab 0 "No" 1 "Yes"
lab val spm_poverty_status spmlab

rename q1b3 physicalhealth_rating
recode physicalhealth_rating (1=5) (2=4) (4=2) (5=1)
lab def physlab 1 "Poor" 2 "Fair" 3 "Good" 4 "Very Good" 5 "Excellent"
lab val physicalhealth_rating physlab
replace physicalhealth_rating = . if physicalhealth_rating > 5

rename q1b4 mentalhealth_rating
recode mentalhealth_rating (1=5) (2=4) (4=2) (5=1)
lab def mentlab 1 "Poor" 2 "Fair" 3 "Good" 4 "Very Good" 5 "Excellent"
lab val mentalhealth_rating mentlab
replace mentalhealth_rating = . if mentalhealth_rating > 5

drop q*

gen wave=1

save wave1.dta, replace
